<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<script type="text/javascript">
    $(function () {
        var email = $('#email').val();
        if (email != null && email.length > 0) {
            $('#sendMail').show();
        } else {
            $('#sendMail').hide();
        }
    } );

    function validateComment() {
        var commentValue = $('#comment').val();
        if (commentValue.length <= 0) {
            validateRejectAndMail();
        }
    }

    function validateRejectAndMail() {
        // $('#comment').show();
        /* var comment = document.getElementById("comment").value;
         alert(comment);*/
        $('#comment').rules("add", {
            required:true,
            messages:{
                required: " Please Enter a Comment " }
        });
    }
</script>

<table class="width-100">
    <s:if test="editMode==2 ">
        <tr>
            <td><s:label value="%{getText('application_comment.label')}"/></td>
            <td colspan="3">
                <s:textarea id="comment" name="landApplication.comment" cssClass="width-595-px"/>
            </td>
        </tr>
    </s:if>
</table>

<div class="form-button-div right">
    <s:if test="editMode==2 ">
        <s:url id="rejectInitApplication" action="rejectInitApplication">
            <s:param name="applicationId" value="landApplication.id"/>
        </s:url>
        <s:url id="approveApplication" action="approveInitApplication">
            <s:param name="applicationId" value="landApplication.id"/>
        </s:url>
        <s:url id="sendMailInitApplication" action="sendMailInitApplication">
            <s:param name="applicationId" value="landApplication.id"/>
        </s:url>

        <s:a href="%{approveApplication}">
            <s:submit value="%{getText('approve_button.label')}" onclick="javascript:return checkFieldsForSyntaxErrorsByElementId('comment')"/>
        </s:a>
        <s:a href="%{rejectInitApplication}">
            <s:submit value="%{getText('reject_button.label')}" onclick="javascript:return checkFieldsForSyntaxErrorsByElementId('comment')" />
        </s:a>
        <s:a href="%{sendMailInitApplication}">
            <s:submit id="sendMail" value="%{getText('send_mail_button.label')}" onclick="javascript:return checkFieldsForSyntaxErrorsByElementId('comment')" />
            <s:hidden name="landApplication.comment"/>
            <s:hidden name="landApplication.id"/>
        </s:a>
    </s:if>
</div>
<s:hidden id="email" name="contacts.email"/>
